<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>cpbtf2.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CPBTF2.1"></a><a href="cpbtf2.f.html#CPBTF2.1">CPBTF2</a>( UPLO, N, KD, AB, LDAB, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          UPLO
      INTEGER            INFO, KD, LDAB, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      COMPLEX            AB( LDAB, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CPBTF2.18"></a><a href="cpbtf2.f.html#CPBTF2.1">CPBTF2</a> computes the Cholesky factorization of a complex Hermitian
</span><span class="comment">*</span><span class="comment">  positive definite band matrix A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The factorization has the form
</span><span class="comment">*</span><span class="comment">     A = U' * U ,  if UPLO = 'U', or
</span><span class="comment">*</span><span class="comment">     A = L  * L',  if UPLO = 'L',
</span><span class="comment">*</span><span class="comment">  where U is an upper triangular matrix, U' is the conjugate transpose
</span><span class="comment">*</span><span class="comment">  of U, and L is lower triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  This is the unblocked version of the algorithm, calling Level 2 BLAS.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  UPLO    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          Specifies whether the upper or lower triangular part of the
</span><span class="comment">*</span><span class="comment">          Hermitian matrix A is stored:
</span><span class="comment">*</span><span class="comment">          = 'U':  Upper triangular
</span><span class="comment">*</span><span class="comment">          = 'L':  Lower triangular
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix A.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  KD      (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The number of super-diagonals of the matrix A if UPLO = 'U',
</span><span class="comment">*</span><span class="comment">          or the number of sub-diagonals if UPLO = 'L'.  KD &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  AB      (input/output) COMPLEX array, dimension (LDAB,N)
</span><span class="comment">*</span><span class="comment">          On entry, the upper or lower triangle of the Hermitian band
</span><span class="comment">*</span><span class="comment">          matrix A, stored in the first KD+1 rows of the array.  The
</span><span class="comment">*</span><span class="comment">          j-th column of A is stored in the j-th column of the array AB
</span><span class="comment">*</span><span class="comment">          as follows:
</span><span class="comment">*</span><span class="comment">          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)&lt;=i&lt;=j;
</span><span class="comment">*</span><span class="comment">          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j&lt;=i&lt;=min(n,j+kd).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, the triangular factor U or L from the
</span><span class="comment">*</span><span class="comment">          Cholesky factorization A = U'*U or A = L*L' of the band
</span><span class="comment">*</span><span class="comment">          matrix A, in the same storage format as A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDAB    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array AB.  LDAB &gt;= KD+1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0: successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0: if INFO = -k, the k-th argument had an illegal value
</span><span class="comment">*</span><span class="comment">          &gt; 0: if INFO = k, the leading minor of order k is not
</span><span class="comment">*</span><span class="comment">               positive definite, and the factorization could not be
</span><span class="comment">*</span><span class="comment">               completed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The band storage scheme is illustrated by the following example, when
</span><span class="comment">*</span><span class="comment">  N = 6, KD = 2, and UPLO = 'U':
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  On entry:                       On exit:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">      *    *   a13  a24  a35  a46      *    *   u13  u24  u35  u46
</span><span class="comment">*</span><span class="comment">      *   a12  a23  a34  a45  a56      *   u12  u23  u34  u45  u56
</span><span class="comment">*</span><span class="comment">     a11  a22  a33  a44  a55  a66     u11  u22  u33  u44  u55  u66
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Similarly, if UPLO = 'L' the format of A is as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  On entry:                       On exit:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     a11  a22  a33  a44  a55  a66     l11  l22  l33  l44  l55  l66
</span><span class="comment">*</span><span class="comment">     a21  a32  a43  a54  a65   *      l21  l32  l43  l54  l65   *
</span><span class="comment">*</span><span class="comment">     a31  a42  a53  a64   *    *      l31  l42  l53  l64   *    *
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Array elements marked * are not used by the routine.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      REAL               ONE, ZERO
      PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            UPPER
      INTEGER            J, KLD, KN
      REAL               AJJ
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.101"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      EXTERNAL           <a name="LSAME.102"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           CHER, <a name="CLACGV.105"></a><a href="clacgv.f.html#CLACGV.1">CLACGV</a>, CSSCAL, <a name="XERBLA.105"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX, MIN, REAL, SQRT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      UPPER = <a name="LSAME.115"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
      IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.116"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) ) THEN
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
         INFO = -2
      ELSE IF( KD.LT.0 ) THEN
         INFO = -3
      ELSE IF( LDAB.LT.KD+1 ) THEN
         INFO = -5
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.126"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CPBTF2.126"></a><a href="cpbtf2.f.html#CPBTF2.1">CPBTF2</a>'</span>, -INFO )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      KLD = MAX( 1, LDAB-1 )
<span class="comment">*</span><span class="comment">
</span>      IF( UPPER ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Compute the Cholesky factorization A = U'*U.
</span><span class="comment">*</span><span class="comment">
</span>         DO 10 J = 1, N
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Compute U(J,J) and test for non-positive-definiteness.
</span><span class="comment">*</span><span class="comment">
</span>            AJJ = REAL( AB( KD+1, J ) )
            IF( AJJ.LE.ZERO ) THEN
               AB( KD+1, J ) = AJJ
               GO TO 30
            END IF
            AJJ = SQRT( AJJ )
            AB( KD+1, J ) = AJJ
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Compute elements J+1:J+KN of row J and update the
</span><span class="comment">*</span><span class="comment">           trailing submatrix within the band.
</span><span class="comment">*</span><span class="comment">
</span>            KN = MIN( KD, N-J )
            IF( KN.GT.0 ) THEN
               CALL CSSCAL( KN, ONE / AJJ, AB( KD, J+1 ), KLD )
               CALL <a name="CLACGV.159"></a><a href="clacgv.f.html#CLACGV.1">CLACGV</a>( KN, AB( KD, J+1 ), KLD )
               CALL CHER( <span class="string">'Upper'</span>, KN, -ONE, AB( KD, J+1 ), KLD,
     $                    AB( KD+1, J+1 ), KLD )
               CALL <a name="CLACGV.162"></a><a href="clacgv.f.html#CLACGV.1">CLACGV</a>( KN, AB( KD, J+1 ), KLD )
            END IF
   10    CONTINUE
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Compute the Cholesky factorization A = L*L'.
</span><span class="comment">*</span><span class="comment">
</span>         DO 20 J = 1, N
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Compute L(J,J) and test for non-positive-definiteness.
</span><span class="comment">*</span><span class="comment">
</span>            AJJ = REAL( AB( 1, J ) )
            IF( AJJ.LE.ZERO ) THEN
               AB( 1, J ) = AJJ
               GO TO 30
            END IF
            AJJ = SQRT( AJJ )
            AB( 1, J ) = AJJ
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Compute elements J+1:J+KN of column J and update the
</span><span class="comment">*</span><span class="comment">           trailing submatrix within the band.
</span><span class="comment">*</span><span class="comment">
</span>            KN = MIN( KD, N-J )
            IF( KN.GT.0 ) THEN
               CALL CSSCAL( KN, ONE / AJJ, AB( 2, J ), 1 )
               CALL CHER( <span class="string">'Lower'</span>, KN, -ONE, AB( 2, J ), 1,
     $                    AB( 1, J+1 ), KLD )
            END IF
   20    CONTINUE
      END IF
      RETURN
<span class="comment">*</span><span class="comment">
</span>   30 CONTINUE
      INFO = J
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CPBTF2.198"></a><a href="cpbtf2.f.html#CPBTF2.1">CPBTF2</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
